﻿<Window x:Class="Hp.Vertica.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        Title="Vertica Management Studio" Height="760" Width="1024" WindowState="Maximized">
    <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="Background" Value="#FFFFFFFF" />
            <Setter Property="BorderThickness" Value="0"/>
        </Style>
        <HierarchicalDataTemplate x:Key="schemaTemplate" ItemsSource="{Binding Tables}">
            <StackPanel Orientation="Horizontal">
                <StackPanel.ContextMenu>
                    <ContextMenu Name="schemaContextMenu">
                        <MenuItem Header="View Definition" Click="ViewSchemaDefinition_Click"></MenuItem>
                        <MenuItem Header="Filter" IsEnabled="False">
                            <MenuItem Header="Remove Filter">
                            </MenuItem>
                            <MenuItem Header="Filter Settings">
                            </MenuItem>
                        </MenuItem>
                    </ContextMenu>
                </StackPanel.ContextMenu>
                <Image Source="Images/Icons/Light/appbar.folder.png" Height="25" />
                <Label >
                    <TextBlock Text="{Binding Path=Name}"></TextBlock>
                </Label>
                <Label Content="{Binding Tables.Count}"></Label>
            </StackPanel>
            <HierarchicalDataTemplate.ItemTemplate >
                <HierarchicalDataTemplate ItemsSource="{Binding Path=Columns}">
                    <StackPanel Orientation="Horizontal" >
                        <StackPanel.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Select Top 1000 Rows" Click="SelectTop1000_Click"></MenuItem>
                                <MenuItem Header="View Definition" Click="ViewTableDefinition_Click"></MenuItem>
                                <MenuItem Header="Delete" IsEnabled="False"></MenuItem>
                                <MenuItem Header="Rename" IsEnabled="False"></MenuItem>
                                <MenuItem Header="Script Table as">
                                    <MenuItem Header="SELECT" Click="Select_Click"></MenuItem>
                                    <MenuItem Header="INSERT" Click="Insert_Click"></MenuItem>
                                    <MenuItem Header="UPDATE" Click="Update_Click"></MenuItem>
                                    <MenuItem Header="DELETE" Click="Delete_Click"></MenuItem>
                                </MenuItem>
                            </ContextMenu>
                        </StackPanel.ContextMenu>
                        <Image Source="Images/Icons/Light/appbar.table.png" Height="25" />
                        <Label >
                            <TextBlock Text="{Binding Path=Name}"></TextBlock>
                        </Label>
                    </StackPanel>
                    <HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <Image Source="Images/Icons/Light/appbar.column.one.png" Height="25" />
                                <Label >
                                    <TextBlock Text="{Binding Path=Name}"></TextBlock>
                                </Label>
                            </StackPanel>
                        </DataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                </HierarchicalDataTemplate>
            </HierarchicalDataTemplate.ItemTemplate>
        </HierarchicalDataTemplate >
        <TreeViewItem x:Key="nodeDatabase" x:Shared ="false" IsExpanded="True">
            <TreeViewItem.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Disconnect" />
                    <MenuItem Header="Edit" />
                    <Separator/>
                    <MenuItem Header="New Query" IsEnabled="False"/>
                    <Separator/>
                    <MenuItem Header="Import" IsEnabled="False">
                        <MenuItem Header="From Microsoft SQL Server" Click="ImportFromSqlServer_Click"/>
                    </MenuItem>
                </ContextMenu>
            </TreeViewItem.ContextMenu>
            <TreeViewItem.Header>
                <StackPanel Orientation="Horizontal">
                    <Image Source="Images/Icons/Light/appbar.database.png" Height="25" />
                    <Label Content="{Binding Path=Name}"></Label>
                </StackPanel>
            </TreeViewItem.Header>
            <TreeViewItem DataContext="{Binding Path=SystemTables}" ItemsSource="{Binding Schemas}" ItemTemplate="{Binding Source={StaticResource schemaTemplate}}">
                <TreeViewItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Filter" IsEnabled="False">
                                    <MenuItem Header="Remove Filter">
                                    </MenuItem>
                                    <MenuItem Header="Filter Settings">
                                    </MenuItem>
                                </MenuItem>
                            </ContextMenu>
                        </StackPanel.ContextMenu>
                        <Image Source="Images/Icons/Light/appbar.folder.png" Height="25" />
                        <Label>System Tables</Label>
                    </StackPanel>
                </TreeViewItem.Header>
            </TreeViewItem>
            <TreeViewItem DataContext="{Binding Path=UserTables}" ItemsSource="{Binding Schemas}" ItemTemplate="{Binding Source={StaticResource schemaTemplate}}">
                <TreeViewItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Filter" IsEnabled="False">
                                    <MenuItem Header="Remove Filter">
                                    </MenuItem>
                                    <MenuItem Header="Filter Settings">
                                    </MenuItem>
                                </MenuItem>
                            </ContextMenu>
                        </StackPanel.ContextMenu>
                        <Image Source="Images/Icons/Light/appbar.folder.png" Height="25" />
                        <Label>Tables</Label>
                    </StackPanel>
                </TreeViewItem.Header>
            </TreeViewItem>
            <TreeViewItem DataContext="{Binding Path=UserViews}" ItemsSource="{Binding Schemas}" ItemTemplate="{Binding Source={StaticResource schemaTemplate}}">
                <TreeViewItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Filter" IsEnabled="False">
                                    <MenuItem Header="Remove Filter">
                                    </MenuItem>
                                    <MenuItem Header="Filter Settings">
                                    </MenuItem>
                                </MenuItem>
                            </ContextMenu>
                        </StackPanel.ContextMenu>
                        <Image Source="Images/Icons/Light/appbar.folder.png" Height="25" />
                        <Label>Views</Label>
                    </StackPanel>
                </TreeViewItem.Header>
            </TreeViewItem>
        </TreeViewItem>
    </Window.Resources>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="FILE">
                <MenuItem Header="New">
                    <MenuItem Header="Connection..." x:Name="miNewConnection">
                    </MenuItem>
                    <MenuItem Header="Query">
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="Open" IsEnabled="False">
                </MenuItem>
            </MenuItem>
            <MenuItem Header="TOOLS">
                <MenuItem Header="WPF Control Template" x:Name="btnControlTemplate" ></MenuItem>
                <MenuItem Header="Data Migration Tool" x:Name="btnSqlServerMigration" IsEnabled="False"></MenuItem>
            </MenuItem>
        </Menu>
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="4*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Label Grid.Column="0" Grid.Row="0">Database Explorer</Label>
            <StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal">
                <Button x:Name="btnNewConnection">
                    <Image Source="Images/Icons/Light/appbar.add.png" Height="25"></Image>
                </Button>
                <Button x:Name="btnRefresh" IsEnabled="False">
                    <Image Source="Images/Icons/Light/appbar.refresh.png" Height="25"></Image>
                </Button>
                <Button x:Name="btnNewQuery" IsEnabled="False">
                    <Image Source="Images/Icons/Light/appbar.page.add.png" Height="25"></Image>
                </Button>
            </StackPanel>
            <TreeView Grid.Column="0" Grid.Row="2"  x:Name="panelDatabases" Margin="2" VirtualizingStackPanel.IsVirtualizing="True"
            VirtualizingStackPanel.VirtualizationMode="Recycling"></TreeView>
            <GridSplitter Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Width="2" />
            <GridSplitter Grid.Column="1" Grid.Row="0" Grid.RowSpan="3" Width="2" />
            <TabControl Grid.Column="1" Grid.Row="0" Grid.RowSpan="3">
                <TabItem Header="Script Panel">
                    <TextBox x:Name="txtScriptPanel"></TextBox>
                </TabItem>
            </TabControl>
        </Grid>
    </DockPanel>
</Window>
